#include <stdio.h>
#include <stdlib.h>
#include <pthread.h> 
#include <time.h>


const int thread_num = 32;
int* A,B,C;

pthread_mutex_t mutex[thread_num]; 

typedef struct{
	int *A;
	int *B;
	int *C;
}MY_ARGS;

void* mysum(void* args){
	int i;
	MY_ARGS* my_args = (MY_ARGS*) args;
	int first = my_args->first;
	int last = my_args->last;

	for(i=first;i<last;i++){
		s = s + arr[i];
	}
	my_args -> result = s;
	return NULL;
}

int main(){	
	int i;
	A = malloc(sizeof(int) * task_num);
	B = malloc(sizeof(int) * task_num);
	C = malloc(sizeof(int) * task_num);
	for(i=0;i<task_num;i++){
		A[i]=i;
		B[i]=-i;
	}


 	int thread_num = 2;
 	pthread_t th[thread_num];

 	MY_ARGS args={A,B,C};
	
	for(i=0;i<thread_num;i++){
		pthread_create(&th[i],NULL,mysum,&args);
	}
	
	for(i=0;i<thread_num;i++){
		pthread_join(th[i],NULL);
	}	
	//display result
	for(i=0;i<thread_num;i++){
		printf("%d ", A[i]);
	}	
	printf("\n");
	for(i=0;i<thread_num;i++){
		printf("%d ", B[i]);
	}
	printf("\n");
	for(i=0;i<thread_num;i++){
		printf("%d ", C[i]);
	}
	printf("\n");
	return 0;
}
